package zzzhc.image.recognize;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;

public class SerializeUtil {

	private SerializeUtil() {
	}

	public static void saveImageRecognizer(ImageRecognizer recognizer, OutputStream out)
			throws IOException {
		ObjectOutputStream oos = new ObjectOutputStream(out);
		oos.writeObject(recognizer);
		oos.flush();
	}

	public static ImageRecognizer loadImageRecognizer(InputStream in)
			throws IOException {
		ObjectInputStream ois = new ObjectInputStream(in);
		try {
			ImageRecognizer recognizer = (ImageRecognizer) ois.readObject();
			return recognizer;
		} catch (ClassNotFoundException e) {
			throw new RuntimeException(e);
		}
	}

}
